﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Termites.Behaviors
{
    class AutoMovementBehavior : Behavior
    {
        private int lastDirection = 0;
        Random r = new Random();
        public override void move(GameTime gameTime, KeyboardState keyboardState, ref float direction, ref Vector2 position)
        {
            if (gameTime.TotalGameTime.Milliseconds == 0)
            {
                int randomDirection = r.Next(4);
                lastDirection = randomDirection;
            }
            switch (lastDirection)
            {
                case 0:
                    direction = Termite.RIGHT;
                    position.X += Termite.SPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    break;
                case 1:
                    direction = Termite.LEFT;
                    position.X -= Termite.SPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    break;
                case 2:
                    direction = Termite.UP;
                    position.Y -= Termite.SPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    break;
                case 3:
                    direction = Termite.DOWN;
                    position.Y += Termite.SPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    break;
            }
        }
    }
}
